import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('127.0.0.1'))
channel = connection.channel()

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='',  # 简单模式
                      routing_key='hello',  # 指定队列
                      body='Hello World')

print(" [x] Sent 'Hello World'")
